import React from 'react';
import { Router, Route, IndexRoute } from 'react-router';

function loadRoute(cb) {
  return (module) => cb(null, module.default);
}
function errorLoading(err) {
  console.error('Dynamic page loading failed', err);
}

const App = (location, cb) => {
    import('../App').then(loadRoute(cb)).catch(errorLoading)
};

const Home = (location, cb) => {
  import('./Home/Home').then(loadRoute(cb)).catch(errorLoading);
};

const Qhh = (location, cb) => {
    import('./Qhh/Qhh').then(loadRoute(cb)).catch(errorLoading);
};

const Qhhs = (location, cb) => {
    import('./Qhhs/Qhhs').then(loadRoute(cb)).catch(errorLoading);
};

const Ana = (location, cb) => {
    import('./Ana/Ana').then(loadRoute(cb)).catch(errorLoading);
};

const Anas = (location, cb) => {
    import('./Anas/Anas').then(loadRoute(cb)).catch(errorLoading);
};

const His = (location, cb) => {
    import('./His/His').then(loadRoute(cb)).catch(errorLoading);
};

const Hiss = (location, cb) => {
    import('./Hiss/Hiss').then(loadRoute(cb)).catch(errorLoading);
};



const Routes = ({history}) =>
  <Router history={history}>
      <Route path="/" getComponent={App}>
          <IndexRoute getComponent={Home} />
          <Route path="qhh" getComponent={Qhh} />
          <Route path="qhhs" getComponent={Qhhs} />
          <Route path="ana" getComponent={Ana} />
          <Route path="anas" getComponent={Anas} />
          <Route path="his" getComponent={His} />
          <Route path="hiss" getComponent={Hiss} />
      </Route>
  </Router>;

export default Routes;
